import request from "@/utils/request";
import type { AttrDataArr, AttrData } from "./model/attr";
//获取一级路由的数据
export const reqC1List = () =>
  request.get<any, AttrDataArr>("/admin/product/getCategory1");
//获取二级路由的数据
export const reqC2List = (category1Id: number) =>
  request.get<any, AttrDataArr>(`/admin/product/getCategory2/${category1Id}`);
//获取三级路由的数据
export const reqC3List = (category2Id: number) =>
  request.get<any, AttrDataArr>(`/admin/product/getCategory3/${category2Id}`);

//获取页面属性的数据
export const reqAttrList = (c1: number|string,c2: number|string,c3: number|string ) =>
  request.get(`/admin/product/attrInfoList/${c1}/${c2}/${c3}`);

//页面1的添加和修改接口
export const reqSaveAttrInfo = (data:any)=> request.post('/admin/product/saveAttrInfo',data)

//删除的逻辑
export const deleteAttr = (attrId:any)=>request.delete(`/admin/product/deleteAttr/${attrId}`)

//添加和修改的请求
export const reqAddOrUpdataList = (data:any)=>{
  if(data.id){
    request.post('/admin/product/saveSpuInfo',data)
  }else{
    request.post('/admin/product/updateSpuInfo',data)
  }
}